import React from "react";
import { FormContext } from "./FormContext";

import useForm from "./useForm";
export default function MyForm({ children, form, onFinish, onFinishFailed }) {
      let [formData] = useForm({ form });

      function submitForm(e) {
            e.preventDefault();
            onFinish(formData.getStore());
      }

      return (
            <form onSubmit={submitForm}>
                  <FormContext.Provider value={formData}>
                        {children}
                  </FormContext.Provider>
            </form>
      );
}
